const app = getApp();
const common = require('../../../utils/common.js');
const api = require('../../../config/api.js');
var WxParse = require('../../../lib/wxParse/wxParse');
Page({

  data: {
   
  },
  
  onLoad(options){
    this.setData({
      options
    })
  },
  getGame(){
    let that = this;
    util.request(api.getGameList, {
      openid: wx.getStorageSync('openid')
    }).then(function (res) {
      console.log(res)
      if (res.stat == 1) {
        that.setData({
         hdpicker:res.data
        })
      }
    })
  },

  NavChange(e) {
    wx.reLaunch({
      url: '/pages/index/index?curPage=' + e.currentTarget.dataset.cur,
    })

  },
  onReady: function (res) {
    this.videoContext = wx.createVideoContext('prew_video');
  },

  
  //提交报名
  formSubmit(e){
    let that = this;
    if(!e.detail.value.name){
      common.showErrorToast("请输入名字")
      return
    }
    if(!e.detail.value.phone){
      common.showErrorToast("请输入联系电话")
      return
    }
    if(!e.detail.value.email){
      common.showErrorToast("请输入身份证后六位")
      return
    }
    if(!e.detail.value.roomNo){
      common.showErrorToast("请输入业主楼号或准客户瓯客会会员号")
      return
    }
    that.actJoin(e)
  },
  //活动报名
  actJoin(e) {
    let that = this;
    common.request(api.actJoin, {
      actId: that.data.options.id,
      userName:e.detail.value.name,
      mobile:e.detail.value.phone,
      idCard:e.detail.value.email,
      roomNo:e.detail.value.roomNo,
      shareId:that.data.options.Mid === 'undefined'?0:that.data.options.Mid
    }, 'post').then(function (data) {
      if (data.type === 'success') {
        common.showSuccessToast(data.content);
        setTimeout(function () {
          wx.navigateBack({
            delta: 2
          })
        }, 1500);
      }else{
        common.showSuccessToast("报名失败");
      }
    });
  },
  
  //去充值
  toRecharge: function () {
    wx.redirectTo({
      url: '/pages/ucenter/recharge/recharge'
    })
  },

});